{
  "properties" : { },
  "id" : "0b83cec08df8430d989bdf5059d3d6c8",
  "script" : null,
  "groupId" : "fe6c046a6a0c4e388989393ac6b92150",
  "name" : "填写",
  "createTime" : null,
  "updateTime" : 1744900081254,
  "lock" : null,
  "createBy" : null,
  "updateBy" : "管理员",
  "path" : "complete",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n    \"taskId\": \"1eb08918-1b98-11f0-82d0-f4b3016ece8b\",\r\n    \"variables\":{\r\n        \"numberA\": 3.40,\r\n        \"numberB\": 4.00\r\n    }\r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"code\": 401,\n    \"msg\": \"任务不存在\"\n}",
  "description" : null,
  "requestBodyDefinition" : null,
  "responseBodyDefinition" : null
}
================================
import 'org.activiti.engine.RepositoryService' as repositoryService;
import 'org.activiti.engine.RuntimeService' as runtimeService;
import 'org.activiti.engine.TaskService' as taskService;
import 'com.wiwf.model.security.service.SysTokenService' as sysTokenService;
import org.activiti.api.process.model.ProcessInstance;
import org.activiti.engine.task.Task;
import log;

var user = sysTokenService.getTokenUser(cookie[sysTokenService.getTokenKey()]);
var roleCode = user.roleCode;
var userId = user.userId;
var unitId = user.unitId;
    
    body.variables['userId'] = userId;
    body.variables['unitId'] = unitId;

    Task task = taskService.createTaskQuery().taskId(body.taskId).singleResult();
    if(! task){
        exit 401, "任务不存在"
    }

    if(task.getFormKey()){
        var formKey= task.getFormKey().toLowerCase();
        db.table(formKey).primary('id').save(body.variables);
    }
    try {
        var completeBody = body.variables;
        completeBody['role'] = roleCode;
        taskService.complete(body.taskId, body.variables);
    } catch(e) {
        exit 401, e.message
    }

return "ok";